package platform.bio;

import java.io.OutputStream;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;

public class ChannelHandler {
    Socket socket;
    Charset charset;

    public ChannelHandler(Socket socket, Charset charset) {
        this.socket = socket;
        this.charset = charset;
    }


    public void writeAndFlush(Object msg) {
        OutputStream outputStream = null;
        try {
            outputStream = socket.getOutputStream();
            outputStream.write(msg.toString().getBytes(charset));
            outputStream.flush();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public Socket socket(){
        return socket;
    }



}
